<template>
  <div class="_wz_hiddenTroubleAdd">
    <Card>
      <p slot="title">隐患排查</p>
      <div style="margin:0 0 10px;" class="_wz_ztList_cont">
        <div style="display: inline-block;">
          隐患排查：<span class="_wz_ztList_cont_span">{{!!selectData.riskInspectName ? selectData.riskInspectName : '--'}}</span>
          <Divider type="vertical" />
        </div>
        <div style="display: inline-block;">
          排查类型：
          <Tag color="primary" type="dot" v-if="selectData.riskInspectType == 1">计划排查</Tag>
          <Tag color="success" type="dot" v-if="selectData.riskInspectType == 2">主动排查</Tag>
          <Divider type="vertical" />
        </div>
        <div style="display: inline-block;">
          排查数量：<span class="_wz_ztList_cont_span">{{!!selectData.riskPositionItemCheckCount ? selectData.riskPositionItemCheckCount :0}} / {{!!selectData.riskPositionItemAllCount ? selectData.riskPositionItemAllCount :0}}  项</span>
          <Divider type="vertical" />
        </div>
        <div style="display: inline-block;">
          隐患数量：<span class="_wz_ztList_cont_span">{{!!selectData.riskPositionItemAtCount ? selectData.riskPositionItemAtCount :0}}  项</span>
          <Divider type="vertical" />
        </div>
        <div style="display: inline-block;">
          排查状态：
          <Tag color="error" type="dot" v-if="selectData.riskInspectState == 0">未开始</Tag>
          <Tag color="primary" type="dot" v-if="selectData.riskInspectState == 1">排查中</Tag>
          <Tag color="success" type="dot" v-if="selectData.riskInspectState == 2">已完成</Tag>
          <Divider type="vertical" />
        </div>
        <div style="display: inline-block;">
          隐患部位：<span class="_wz_ztList_cont_span">{{!!selectData.riskPositionName ? selectData.riskPositionName : '--'}}</span>
          <Divider type="vertical" />
        </div>
        <div style="display: inline-block;">
          隐患类型：
          <Tag color="success" type="dot" v-if="selectData.riskPositionType == 1">基础管理</Tag>
          <Tag color="primary" type="dot" v-if="selectData.riskPositionType == 2">设备设施</Tag>
          <Tag color="warning" type="dot" v-if="selectData.riskPositionType == 3">作业活动</Tag>

          <Divider type="vertical" />
        </div>
        <div style="display: inline-block;">
          特种设备：<span class="_wz_ztList_cont_span">{{!!selectData.riskPositionDeviceState ? '是' : '否'}}</span>
          <Divider type="vertical" />
        </div>
        <div style="display: inline-block;">
          排查部门：<span class="_wz_ztList_cont_span">{{!!selectData.riskInspectInOrgName ? selectData.riskInspectInOrgName : '--'}}</span>
          <Divider type="vertical" />
        </div>
        <div style="display: inline-block;">
          排查人员：<span class="_wz_ztList_cont_span">{{!!selectData.riskInspectUserName ? selectData.riskInspectUserName : '--'}}</span>
          <Divider type="vertical" />
        </div>
        <div style="display: inline-block;">
          时间范围：<span class="_wz_ztList_cont_span">{{!!selectData.riskInspectStartDate ? selectData.riskInspectStartDate : '--'}}  至 {{!!selectData.riskInspectEndDate ? selectData.riskInspectEndDate : '--'}}</span>
          <Divider type="vertical" />
        </div>
        <div style="display: inline-block;">
          运输企业：<span class="_wz_ztList_cont_span">{{!!selectData.deptName ? selectData.deptName : '--'}}</span>
          <Divider type="vertical" />
        </div>
        <div style="display: inline-block;">
          创建时间：<span class="_wz_ztList_cont_span">{{!!selectData.createTime ? selectData.createTime : '--'}}</span>
        </div>
      </div>
    </Card>

    <Card style="margin: 10px 0 0 0;" class="_wz_indentation_ivu-table-wrapper">
      <p slot="title">排查清单</p>
      <wzTbale ref="wzTbale" :tableData="tableData"></wzTbale>
    </Card>

    <Drawer title="隐患排查" v-model="riskType" width="820" :mask-closable="false" :draggable="true">
      <hiddenPerilsReport v-if="riskType" @closeFun="closeFun" :selectData="formData"></hiddenPerilsReport>
    </Drawer>



    <Drawer title="隐患排查" v-model="riskTypeSee" width="990" :mask-closable="false" :draggable="true">
      <hiddenDetails v-if="riskTypeSee" :selectData="formData"></hiddenDetails>
    </Drawer>


    <Spin size="large" fix v-if="spinShow"></Spin>

  </div>
</template>
<script>
  import wzTbale from "../../components/table/table";
  import hiddenDetails from "./hiddenDetails";// hiddenDetails  隐患详情
  import hiddenPerilsReport from "./hiddenPerilsReport";// hiddenPerilsReport  排查
  export default {
    components: {
      wzTbale,//列表
      hiddenDetails,//隐患详情
      hiddenPerilsReport,//排查
    },
    props: ['selectData'],//接收来自父组件的数据
    data() {
      return {
        spinShow:false,//本页加载
        riskTypeSee:false,//查看
        riskType: false,//弹框
        formData: {},
        tableData: {
          url: this.apiUrl.riskInspectRiskInspectItemList,//请求地址
          method: 'post',//请求方式
          where: {riskInspectUuid:this.selectData.uuid},//搜索条件
          height: 'auto',//表格高度 auto
          page: false,//分页是否使用
          columns: [//表头数据
            {type: 'index', width: 70, align: 'center', title: '序号'},
            {title: '排查状态', minWidth: 140, key: 'riskInspectItemProcess', render: (h, params) => {
                //0：未排查，1：已上报，2：已核查，3：已整改，4：已验收，5：已完成
                var color = '', test = '';
                if (params.row.riskInspectItemProcess == 0) {
                  color = 'error', test = '未排查';
                } else {
                  color = 'primary', test = '已排查';
                }
                return h('Tag', {props: {type: 'dot',color: color}}, test);
              }
            },
            {title: '隐患部位', minWidth: 140, key: 'riskPositionName'},
            {title: '隐患类型', minWidth: 140, key: 'riskPositionType', render: (h, params) => {
                //  （1：基础管理、2：设备设施、3：作业活动）
                if (params.row.riskPositionType == 1) {
                  return h('Tag', {props: {type: 'dot',color: 'success'}}, '基础管理')
                } else if (params.row.riskPositionType == 2) {
                  return h('Tag', {props: {type: 'dot',color: 'primary'}}, '设备设施')
                } else if (params.row.riskPositionType == 3) {
                  return h('Tag', {props: {type: 'dot',color: 'warning'}}, '作业活动')
                }
              }
            },
            {title: '隐患项目', minWidth: 140, key: 'riskPositionItemName'},
            {title: '隐患等级', minWidth: 140, key: 'riskInspectItemLv', render: (h, params) => {
                //0：不是隐患，1：一般隐患，2：重大隐患
                var color = '', test = '';
                if (params.row.riskInspectItemLv == 0) {
                  color = 'success', test = '无隐患';
                } else if (params.row.riskInspectItemLv == 1) {
                  color = 'warning', test = '一般隐患';
                } else if (params.row.riskInspectItemLv == 2){
                  color = 'error', test = '重大隐患';
                } else{
                  color = '', test = '未排查';
                }
                return h('Tag', {props: {type: 'dot',color: color}}, test);
              }
            },
            {
              title: '操作', fixed: 'right', width: 80,
              render: (h, params) => {
                if (params.row.riskInspectItemProcess == 0) {//未排查
                  return h('span', {
                    style: {"color": "#2d8cf0", "cursor": "pointer"},
                    on: {
                      click: () => {
                        var data = JSON.parse(JSON.stringify(params.row));
                        this.formData = data
                        this.riskType = true;
                      }
                    }
                  }, "排查");
                }else{
                  return h('span', {
                    style: {"color": "#2d8cf0", "cursor": "pointer"},
                    on: {
                      click: () => {
                        this.formData = params.row;
                        this.riskTypeSee = true;
                      }
                    }
                  }, "查看");
                }
              }
            },
          ],
          format: {//返回数据格式
            list: ['data'],//数据list
          },
        },
      }
    },
    beforeCreate() {//beforeCreate创建前状态

    },
    created() {//created创建完毕状态

    },
    beforeMount() {//beforeMount挂载前状态   DOM 元素然后塞入页面的过程

    },
    mounted() {//mounted 挂载结束状态
      var that = this;
    },
    methods: {//执行的方法
      //添加修改触发后关闭刷新
      closeFun(data) {
        var that = this;
        if (data) {//添加修改 刷新表单
          that.$refs.wzTbale.tableLoadData(true);
        }
        that.riskType = false;
      },

    },
    watch: {//监听

    },
    beforeUpdate() {//beforeUpdate 更新前状态

    },
    updated() {//updated 更新完成状态

    },
    beforeDestroy() {//beforeDestroy 销毁前状态

    },
    destroyed() {//destroyed 销毁完成状态

    }
  }
</script>
<style lang="less">
  ._wz_hiddenTroubleAdd {
    .ivu-card-body {
      height: calc(100% - 51px);
    }

    ._wz_ztList_cont {
      letter-spacing: 1px;
      line-height: 30px;

      ._wz_ztList_cont_span {
        margin: 0 10px 0 0;
        color: #01AAED;
        word-break: break-all;
      }
    }
  }
</style>
